package com.example.studyproject.QRCode;

import com.example.studyproject.advice.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ByteArrayResource;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @program: StudyProject
 * @description: 二维码api
 * @author: kangwei
 * @create: 2024-08-13 10:40
 **/
@RestController
@RequestMapping("qr")
public class QRCodeController {

    @Autowired
    private QRCodeService qrCodeService;

    // 生成二维码
    @PostMapping
    public Response generateQRCode(@RequestBody QRCodeInfo qrCodeInfo) {
        return Response.success(qrCodeService.generateQRCode(qrCodeInfo));
    }

    // 生成二维码并返回
    @PostMapping("generateQRCodeV2")
    public Response<ByteArrayResource> generateQRCodeV2(@RequestBody QRCodeInfo qrCodeInfo) {
        return Response.success(qrCodeService.generateQRCodeV2(qrCodeInfo));
    }

}
